home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-05-24 | 4.8 KB | 139 lines | [TEXT/MPS ] |
- /*
- Use this exec to transfer CMS files to your IBM PC or Mac via FT3270 or FTC19.
-
- SYNTAX:
- DOWNLOAD fn ft <fm <micro_filespec>> <( <REPlace> <BINary|TEXt> <)> >
-
- Notes:
- 1) Default filemode is A and is required if micro_filespec is used.
- 2) Default micro_filespec is the concatenation fn.ft
- 3) Wildcards may be used in the CMS and/or the microcomputer filespecs.
- Forward slashes may be typed in place of backward slashes which are
- frequently used as line end characters.
- 4) The REPLACE option means the local file will be replaced with the
- transferred one. The default is to return an error if a local file with
- that name exists.
- 5) The BINARY option means that a binary translation will take place with no
- ebcdic to ASCII translation and no CR/LF's inserted in the local file.
- 6) The TEXT option means that the program will perform the ebcdic/ASCII
- translation, strip trailing blanks off fixed length records, and insert
- CR/LF in the local file.
- 7) The default is to let the micro decide whether to make the transfer TEXT
- or BINARY and so inform the CMS program.
-
- */
-
- /* modified for mac to preserve slash marks kevin 11/3/87 */
- /* 5-5-88 Rich K split path/name based on forward or backslashes */
- /* 5-13-88 RICH K. FIX BUG WHEN RDR FILE ARRIVES SPOOLED TO CURRENT */
- /* READER SETTING */
-
- address 'COMMAND'
-
- /* Parse the arguments and see if help is obviously needed */
-
- parse upper arg FN FT FM . '(' opts ')'
- parse arg . . . FSpec '('/* get FSpec in mixed case */
-
- if FN = '' | FN = '?' then signal help
- if FT = '' | length( FM ) > 2
- then do
- say 'Invalid CMS file specification'; exit 1
- end
-
- /*
- Parse up the micro filespec into drive&path, name, and extension. The
- drive&path part is always used, but the file name and/or extension will
- be derived from the CMS FN and/or FT if '*' is used or the whole thing
- is blank.
- */
-
- FSpec = strip( translate( FSpec, ' ', '"' ) ) /* / = \ & remove "s */
- NamePos = max( lastpos( ':', FSpec ), lastpos( '\', FSpec ) )
- NamePos = max( NamePos, lastpos( '/', FSpec ) )
- path = left( FSpec, NamePos ) /* split the drive & path */
- FSpec = substr( FSpec, NamePos+1 ) /* from the filename */
-
- if FSpec = '' then FSpec = '*.*' /* blank filename = use default */
-
- do i = 1 to 2 /* check for wildcards */
- StarPos.i = pos( '*', FSpec )
- if StarPos.i > 0 then FSpec = delstr( FSpec, StarPos.i, 1 )
- end
-
- SepPos = verify( FSpec, ' .', 'MATCH' )
- if StarPos.1 > 0 & StarPos.2 = 0, /* just one wildcard... */
- & StarPos.1 > SepPos & SepPos > 0 /* after a seperator character? */
- then do /* then make FT, not FN, wild */
- StarPos.2 = StarPos.1
- StarPos.1 = 0
- end
-
- /* Parse the options string */
-
- rep = 'N' /* set default flags */
- bin = 'D'
-
- do while( opts ^= '' )
- parse var opts opt opts /* get the next option word */
-
- select
- when abbrev( 'REPLACE', opt, 3 ) then rep = 'R' /* REPlace */
- when abbrev( 'BINARY', opt, 3 ) then bin = 'B' /* BINary */
- when abbrev( 'TEXT', opt, 3 ) then bin = 'T' /* TEXt */
- otherwise do
- say "Invalid option: '"opt"'"; exit 1
- end
- end /* end select */
- end /* end do */
-
- ConByte = 'D' || bin || rep /* generate control byte */
-
- /* Remember whether messages etc. were on or off */
-
- 'MAKEBUF' /* start a new console stack */
- BufNum = rc
-
- 'CPSTACK LIFO QUERY SET'
- pull . ; pull . ; pull .
- pull 'IMSG' imsg ',' .
- pull . ; pull .
- pull 'MSG' msg ',' . 'WNG' wng ',' .
-
- 'CPSTACK Q C' /* CHECK READER SETTING */
- pull 'RDR' rdrnum 'CL' rdrcl rdrcont rdrhold rdreof rdrready
- 'CP NOTREADY C'
-
- /* Run the file transfer program to download the file(s) */
-
- 'LISTFILE' FN FT FM '(STACK' /* get file name(s) */
- if rc ^= 0 then say 'CMS file' FN FT FM 'not found'
-
- do queued() while( rc = 0 ) /* loop thru each file stacked */
- pull FN FT FM .
-
- MicroSpec = FSpec
- if StarPos.2 > 0 then MicroSpec = insert( FT, MicroSpec, StarPos.2-1 )
- if StarPos.1 > 0 then MicroSpec = insert( FN, MicroSpec, StarPos.1-1 )
-
- 'FT3270 "'path||MicroSpec'"' ConByte FN FT FM /* do the download */
- end /* end do loop */
-
- /* Restore msg processing & exit */
-
- rrc = rc /* save RC from last command */
- 'CP SET MSG' msg /* restore settings */
- 'CP SET WNG' wng
- 'CP SET IMSG' imsg
- if rdrready = 'READY' then 'CP READY C'
- 'DROPBUF' BufNum /* drop our console stack */
- exit rrc
-
- /* Help screen -- Show the comments at the front of this file */
-
- Help:
- 'VMFCLEAR'
- do i = 2 while( sourceline( i ) ^= '*/' )
- say sourceline( i )
- end
-